﻿using System.Configuration;
using System.Linq;

public class AppSettings
{
    /// <summary>
    /// 获取配置文件路径
    /// </summary>
    /// <returns></returns>
    public static string Get(string app_setting_name)
    {
        string cfg_path = string.Empty;

        bool hasKey = ConfigurationManager.AppSettings.AllKeys.Count(k => k.Equals(app_setting_name)).Equals(1);

        if (hasKey)
            cfg_path = ConfigurationManager.AppSettings.Get(app_setting_name);

        return cfg_path;
    }

    public static void Set(string app_setting_name, string value)
    {
        bool hasKey = ConfigurationManager.AppSettings.AllKeys.Count(k => k.Equals(app_setting_name)).Equals(1);

        if (hasKey)
            ConfigurationManager.AppSettings.Set(app_setting_name, value);
        else
            ConfigurationManager.AppSettings.Add(app_setting_name, value);
    }
}
